<template>
	<view>
		<u-popup v-model="show" mode="bottom">
			<scroll-view scroll-y="true" style="height: 500rpx;">
				<view v-for="(item, index) in list" :key="index">
					{{item.content}}
				</view>
			</scroll-view>
			<view>
				保存
			</view>
		</u-popup>
	</view>
</template>

<script>
	import {
		getComments,
		addComments
	} from '@/api/common.js'
	export default {
		name:"Comments",
		data() {
			return {
				list: [],
				show: false,
			};
		},
		methods: {
			open(resId, resType) {
				this.resId = resId;
				this.resType = resType;
				this.getComment();
			},
			
			getComment() {
				const params = {
					resId: this.resId,
					resType: this.resType,
					pageNum: 0,
					pageSize: 999,
				}
				getComments(params).then(res => {
					console.log(res);
					this.list = res.data.comments;
					this.show = true;
				})
			},
			
			addComment(item) {
				const params = {
					content: '这是一条评论1',
					resId: this.resId,
					resType: this.resType
				}
				addComments(params).then(res => {
					console.log(res);
				})
			}
		}
	}
</script>

<style lang="scss">
	
</style>
